<%@page import="com.ym.b2b.cache.configcache.WebAppConfig"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="b" uri="/b2b-tags"%>
<!--响应式布局 -->

<!--[if lte IE 8]><script type="text/javascript" src="/theme/default/js/ie.js?v=2.1"></script><![endif]-->
<link rel="stylesheet" type="text/css"
	href="<c:url value="/views/jsp/brand/lib/css/global.css" />">
<link href="<c:url value="/views/jsp/brand/lib/css/brand.css" />"
	rel="stylesheet" type="text/css">
<link href="<c:url value="/views/jsp/brand/lib/css/list.css" />"
	rel="stylesheet" type="text/css">
<link
	href="<c:url value="/views/jsp/product/shoppingcart/css/select.css" />"
	rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript"
	src="<c:url value="/views/jsp/product/shoppingcart/js/jQuery-shopping.js" />"></script>


<script>
	setFocus(4);
</script>
<div style="margin: 0 auto; width: 1190px;">
	<div class="mianbox">
		<div class="weizhi fl">
			<h2 id="poplogin">首页</h2>
			<span>&gt;</span>
			<h2>
				<a href="<c:url value="/product/searchCommendProduct.s" />">推荐品种</a>
			</h2>
		</div>
		
		<div class="paixu_xz fl" id="search_condition">
			<div class="paixu_xuanzhe fl">
				<ul>
					<li><a href="javascript:chooseType(0)">图片明细</a></li>
					<li><a href="javascript:chooseType(1)">列表显示</a></li>
				</ul>

				<div class="ye fr">
					<c:if test="${result.page.page gt  1 }">
						<div class="xia fl">
							<a href="${result.page.pageUrl }&page=${result.page.page-1}">上一页</a>
						</div>
						<a href="${result.page.pageUrl }&page=${result.page.page-1}"
							class="prev"></a>
					</c:if>
					<c:if test="${result.page.totalPage gt result.page.page}">
						<div class="shang fl">
							<a href="${result.page.pageUrl }&page=${result.page.page+1}">下一页</a>
						</div>
					</c:if>
				</div>
				<div class="tiao fr">
					<font>共</font> <font style="color: #ac1d1f;">${result.page.totalRow}</font>
					<font>个商品</font> <font style="margin-left: 14px; display: inline;">${result.page.page}/${result.page.totalPage}</font>
				</div>
			</div>
		</div>
		<div class="shop_filter mt10" id="TPXS">
			<div class="filter_result brand-page mt10">
				<div id="list_view" class="big_img_list">
					<c:forEach items="${result.rows }" var="p1" varStatus="varstatus">
						<dl class="list_info goods_item_info ">
							<dt class="info_img" productid="1">
								<a
									href="<c:url value="/product/showProductDetail.s" />?productCode=${p1.productCode}"
									class="info_img"> <img class="lazy"
									data-original="<%=WebAppConfig.getPicPath() %>${p1.middlePic}"
									alt="${p1.chsName }" style="display: inline-block;">
								</a>
							</dt>
							<dd class="first_dd">
								<p class="list_product_name">
									<a
										href="<c:url value="/product/showProductDetail.s" />?productCode=${p1.productCode}"
										target="_blank" class="fl productName">${p1.chsName }</a>
								</p>
								<p>规格：${p1.productSpec}</p>
								<p class="company">${p1.producingName}</p>
								<p>
									库存:
									<c:if test="${not empty sessionScope.WEB_USER_TOKEN}">
                          ${p1.stockNum}
                   </c:if>
									<c:if test="${empty sessionScope.WEB_USER_TOKEN}">
				 	---
				</c:if>
								</p>
							</dd>
							<div class="handle mt10">
								<a href="javascript:;" class="big_show loginBtn addUserFavalit"
									title="${p1.chsName }" productCode="${p1.productCode }">收藏</a>
							</div>
							</dd>
						</dl>
					</c:forEach>

				</div>
				<c:import url="/views/jsp/product/import/product_page_info.jsp" />
			</div>
		</div>

		<div class="mianbox" id="LBXS">
			<div id="M-main-b" style="background: white;">
				<c:forEach var="product" items="${result.rows }"
					varStatus="varstatus">
					<div class="M-main-list"
						style="width: 1180px;<c:if test="${varstatus.count%2 == '0'}">background: #fafafa;</c:if>">
						<div class="M-main-A left">
							<h3>
								<a
									href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }">
									<p>${product.chsName }</p>
								</a>
							</h3>
						</div>
						<div class="M-main-B left">
							<a
								href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }">
								<p>规格： ${product.productSpec } / ${product.packingUnit }</p>
							</a>
						</div>

						<div class="M-main-D left">
							<a
								href="<c:url value="/product/showProductDetail.s" />?productCode=${product.productCode }">
								<p>生产厂家: ${product.producingName }</p>
							</a>
						</div>
						<div class="M-main-E left">
							<p>
								库存：
								<c:if test="${not empty sessionScope.WEB_USER_TOKEN}">
                        			${product.stockNum} ${product.packingUnit }
                 				</c:if>
								<c:if test="${empty sessionScope.WEB_USER_TOKEN}">
					 				登录查看
								</c:if>
							</p>
						</div>
					</div>
				</c:forEach>
				<c:import url="/views/jsp/product/import/product_page_info.jsp" />
			</div>
		</div>

	</div>
</div>
<script type="text/javascript">
	$(function() {
		layer.use('extend/layer.ext.js');
		chooseType(0);
		//加入收藏
		$(".addUserFavalit")
				.click(
						function() {
							var productCode = $(this).attr("productCode");
							var objectName = $(this).attr("title");
							layer
									.prompt(
											{
												title : '输入收藏备注，并确认',
												type : 3,
												val : $(this).attr("title")
											},
											function(pass) {
												var p = {
													"productCode" : productCode,
													"notes" : pass,
													"type" : "product",
													"url" : "/product/showProductDetail.s?productCode="
															+ productCode,
													"objectName" : objectName
												};
												$.ajax({
															type : "post",
															data : p,
															dataType : "json",
															url : "<c:url value='/trade/addUserFavorites.s' />",
															success : function(
																	data) {
																if (data.code == "200") {
																	layer.msg(
																					"加入收藏成功",
																					1,
																					{
																						type : 1,
																						shade : [
																								0.2,
																								'#ccc' ]
																					});
																} else {
																	layer.msg(data.result,1,
																					{
																						type : 8,
																						shade : [
																								0.2,
																								'#ccc' ]
																					});
																}
															}
														});
											});

						});
	});
	
	//控制显示和隐藏
	function chooseType(v){
		if(v=="0"){
			$("#TPXS").show();
			$("#LBXS").hide();
		}
		if(v=="1"){
			$("#LBXS").show();
			$("#TPXS").hide();
		}
	}
</script>

